package com.systop.workview.controller;
import com.systop.common.pojo.Student;
import com.systop.common.util.ResponseResult;
import com.systop.workview.service.StudentClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/workview1")
public class StudentController {

    //编译器报错，无视。 因为这个Bean是在程序启动的时候注入的，编译器感知不到，所以报错。
    @Autowired
    StudentClientService studentClientService;

    //login
    @PostMapping (value = "/studentLogin")
    public ResponseResult studentLogin(@RequestParam(value="sno") String sno, @RequestParam (value="password") String password) {
        return studentClientService.studentLogin(sno, password);
    }
    //查全部
    @PostMapping (value = "/studentSupList")
    public ResponseResult studentSupList() {
        return studentClientService.studentSupList();
    }
    //根据tno查询
    @PostMapping (value = "/studentSupList1")
    public ResponseResult updataSupervice1(@RequestParam(value = "sno") String sno) {
        return studentClientService.studentSupList1(sno);
    }
    //添加
    @PostMapping (value = "/studentAdd")
    public ResponseResult suudentadd(@RequestParam(value="sno") String sno, @RequestParam (value="password") String password,@RequestParam(value="name") String name, @RequestParam (value="college_name") String college_name,@RequestParam(value="grade") String grade, @RequestParam (value="class_name") String class_name,@RequestParam(value="remark") String remark) {
        System.out.println(sno+"-"+password+"-"+name+"-"+college_name+"-"+grade+"-"+class_name+"-"+remark);
        return studentClientService.studentAdd(sno,password,name,college_name,grade,class_name,remark);
    }

    //修改
    @PostMapping (value = "/updataStudent")
    public ResponseResult updataStudent(@RequestParam(value="sno") String sno, @RequestParam (value="password") String password,@RequestParam(value="name") String name, @RequestParam (value="college_name") String college_name,@RequestParam(value="grade") String grade, @RequestParam (value="class_name") String class_name,@RequestParam(value="remark") String remark) {
        return studentClientService.updataStudent(sno,password,name,college_name,grade,class_name,remark);
    }
    //删除
    @PostMapping (value = "/delStudent")
    public ResponseResult delStudent(@RequestParam(value = "sno") String sno) {
        return studentClientService.delStudent(sno);
    }
//-----------------------------------选课------------------
   // 添加
    @PostMapping (value = "/sxadd")
    public ResponseResult sxadd(@RequestParam(value = "sno")String sno, @RequestParam(value = "elective_course_id")String elective_course_id
            ,@RequestParam(value = "student_name")String student_name,@RequestParam(value = "remark")String remark)
    {
        return studentClientService.sxadd(sno,elective_course_id,student_name,remark);
    }
    //查看
    @PostMapping (value = "/sxlistid")
    public ResponseResult sxlistid(String sno){
        return studentClientService.sxlistid(sno);
    }
    //删除
    @PostMapping (value = "/sxdel")
    public ResponseResult sxdel(@RequestParam(value = "student_elective_id")String student_elective_id){
        return studentClientService.sxdel(student_elective_id);
    }
    //根据elective_course_id排课id查询
    @PostMapping (value = "/studentSelective_course_id")
    public ResponseResult studentSelective_course_id(@RequestParam(value = "elective_course_id") String elective_course_id){
        return studentClientService.studentSelective_course_id(elective_course_id);
    }



}
